package cn.edu.Bistu.wordsbook;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.Map;

public class SearchActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);

        //接收从MainActivity里穿过来的list
        Bundle bundle = this.getIntent().getExtras();
        ArrayList<Map<String,String>> items = (ArrayList<Map<String, String>>) bundle.getSerializable("result");

        if (items!=null) {
            //为ListView配置Adapter
            SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout.listview_item
                    , new String[]{Words.Word._ID, Words.Word.COLUMN_WORD, Words.Word.COLUMN_MEANING, Words.Word.COLUMN_SAMPLE}
                    , new int[]{R.id.textId, R.id.textWord, R.id.textMeaning, R.id.textSample});
            ListView list = findViewById(R.id.result_list);
            list.setAdapter(adapter);
        }
    }
}